package mainframe;

import java.io.File;

import javax.swing.filechooser.FileFilter;

public class XmlFileFilter extends FileFilter {

	@Override
	public boolean accept(File file) {
		return isXmlFile(file) || file.isDirectory();
	}

	@Override
	public String getDescription() {
		return ".xml";
	}

	private boolean isXmlFile(File file) {
		String[] splittedName = file.getName().split("\\.");
		if ((splittedName.length >= 2)
				&& splittedName[splittedName.length - 1]
						.equalsIgnoreCase("xml")) {
			return true;
		}
		return false;
	}
}
